/**
Nectarine Utility Project is a software interface for the web system 'demovibes'
Copyright (C) 2010  Alexandre LAURENT

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

website: http://code.google.com/p/nectarine-utility-project/
e-mail: lw.demoscene@gmail.com
**/

#include "webdebug.h"

#include <QNetworkReply>
#include <QList>
#include <QByteArray>

#include <QDebug>

void WebDebug :: printInfoNetworkReply(QNetworkReply* pNReply)
{
    int i = 0;
    QList<QByteArray> listHeader = pNReply->rawHeaderList();

    qDebug() << "Read:\n" << pNReply->readAll() << "\nEnd";
    qDebug() << "Error:" << pNReply->error();
    qDebug() << "Attribute QNetworkRequest::HttpStatusCodeAttribute:" << pNReply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
    qDebug() << "Attribute QNetworkRequest::HttpReasonPhraseAttribute:" << pNReply->attribute(QNetworkRequest::HttpReasonPhraseAttribute).toByteArray();
    qDebug() << "Attribute QNetworkRequest::RedirectionTargetAttribute:" << pNReply->attribute(QNetworkRequest::RedirectionTargetAttribute).toUrl();
    qDebug() << "Header QNetworkRequest::ContentTypeHeader:" << pNReply->header(QNetworkRequest::ContentTypeHeader).toByteArray();
    qDebug() << "Header QNetworkRequest::ContentLengthHeader:" << pNReply->header(QNetworkRequest::ContentLengthHeader).toInt();
    qDebug() << "Header QNetworkRequest::LocationHeader:" << pNReply->header(QNetworkRequest::LocationHeader).toUrl();
    qDebug() << "Header QNetworkRequest::CookieHeader:" << pNReply->header(QNetworkRequest::CookieHeader).toList();
    qDebug() << "Header QNetworkRequest::SetCookieHeader:" << pNReply->header(QNetworkRequest::SetCookieHeader).toList();
    qDebug() << "Raw header list:" << listHeader;
    for (i = 0; i < listHeader.size(); ++i)
    {
        qDebug() << "Raw header('" << listHeader.at(i) << "') -> " << pNReply->rawHeader(listHeader.at(i));
     }
}
